<template>
    <div>
      <el-alert :title="_message" type="warning" effect="dark"> </el-alert>
     <el-button @click="qs_cys" :style="{display:_vis_button}">申请解除可用额度限制</el-button>
	</div>

  <el-dialog v-model="_dialogFormVisible" title="申请解除可用额度限制">
     <el-divider ></el-divider>
    
    <el-form :model="_form">   
     
      <el-form-item label="意见" label-width="100px">
          
            <el-input  type="textarea" style="width: 80%"  v-model="_form._content" autocomplete="off"></el-input>
        
      </el-form-item>
     
    
    </el-form>
   
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="_dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="save_qings"
          >保存</el-button
        >
      </span>
    </template>
  </el-dialog>

  
</template>

<script>
import VolHeader from "@/components/basic/VolHeader.vue";
import http from "@/api/http.js";
export default {
  components: { VolHeader},
  data() {
	  return{
		  _message:"桔红色金额为超预算或没有预算",
      _reimid:"",
      _vis_button:"",//none不显示，空为显示
      _dialogFormVisible:false,
      _form:{
        _reimid:null,
        _typeid:null,
        _stepid:null,
        _content:"",
      }
	  }
  },
  setup() {},
  destroyed() {},
  mounted() {
 /*   this.$nextTick(() => {    
     this.$emit("parentCall", ($vue) => {
           console.log($vue.editFormFields)    
          console.log($vue.editFormFields.reim_id)          
          //this.get_init_page($vue.editFormFields.reim_id,$vue);
         
           console.log($vue.editFormFields.username);
                  console.log(this.$store.getters.data().curr.username);
                if ($vue.editFormFields.username.indexOf(this.$store.getters.data().curr.username)==-1){
                 
                       this._vis_button="none";//当前登录的人不是申请人，按钮不显示
                }
						});           
   }) */
  },
  methods: {
      get_init_page(_reimid){//让父窗体调用

        this.$nextTick(() => {  
            this.$emit("parentCall", ($vue) => {
            this._message="桔红色金额为超预算或没有预算";
            let url="/api/Fk_reim/get_reimfloat?reimid="+_reimid;
            http.post(url, {}, true).then((rtn) => {
                let s=rtn.rf_list;
                //this._tickno_rows=rtn.tickno_rows;
                if ($vue.editFormFields.username.indexOf(this.$store.getters.data().curr.username)==-1){
                      this._vis_button="none";//按钮不显示
                 };
              if (s.length>0){//说明申请过
                this._vis_button="none";//申请按钮不显示
                if (s[0].node_type=="sqj_ok"){
                this._message=s[0].remark+",申请时间："+s[0].bdatetime+",反馈时间："+s[0].edatetime+",反馈意见：同意";
                }
                else{
                this._message=s[0].remark+",申请时间："+s[0].bdatetime+",反馈时间："+s[0].edatetime+",反馈意见：稍等,请联系财务人员";
                }
                
              }
                });
            
            })  
        })
      },
		  qs_cys(){//点击申请按钮
           this.$emit("parentCall", ($vue) => { 
              //f=$vue;
             // _message=_message+"id="+$vue.editFormFields.reim_id
             //console.log($vue.editFormFields.reim_id);
             if ($vue.editFormFields.reim_id<=0){
               this.$message.error("请先点击下面‘保存’按钮再申请！")
               return;
             }
             this._form._reimid=$vue.editFormFields.reim_id;
             this._form._typeid=$vue.editFormFields.typeid;
             this._form._stepid=$vue.editFormFields.stepid;
             this._form._content=$vue.editFormFields.reim_id+"号，申请解除可用额度限制。申请人："+this.$store.getters.data().curr.username
             this._dialogFormVisible = true;
						//console.log($vue.editFormFields);
           

				});
      },
      save_qings(){//提交申请解除额度限制
        /* 
        1、提交保存到reimfloat，插入数据，//类型为sqj(申请解除可用的限制)，sqj_ok表示同意解除可用额度限制
        2、隐藏申请按钮；
        3、显示reimfloat审核内容
         */
        
        //this._form._content=$vue.editFormFields.stepid;
        let _tjoptions = encodeURIComponent(JSON.stringify(this._form)); //防止中文
            let url = "/api/customer/save_shenqi?options=" + _tjoptions;
            let _s = [];
            http.post(url, {}, true).then((s) => {
              this._vis_button="none";//隐藏申请按钮；
              this.$Message(s.message);
              if (s.data.newdata.node_type=="sqj_ok"){
               
                //console.log(s);
                this._message=s.data.newdata.remark+",申请时间："+s.data.newdata.bdatetime+",反馈时间："+s.data.newdata.edatetime+",反馈意见：同意";
            
              }else{
                
                //console.log(s);
                this._message=s.data.newdata.remark+",申请时间："+s.data.newdata.bdatetime+",反馈时间："+s.data.newdata.edatetime+",反馈意见：请联系财务人员";
              }
            })
        this._dialogFormVisible = false;
        this.$emit("parentCall", ($vue) => { 
          $vue.boxModel=false;//需要关闭viewgrid的弹出窗体，不让用户点击保存按钮，否则会回滚数据的事务，API(save_shenqi)导致保存不成功！ 2022年5月23日 14:55:32,这点非常重要
        })
      }
  },  
}

</script>
<style scoped>
.el-button--text {
  margin-right: 15px;
}
.el-select {
  width: 300px;
}
.el-input {
  width: 300px;
}
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>